//
//  YXBankViewModel.m
//  CreditCard
//
//  Created by 杨旭 on 2018/1/10.
//  Copyright © 2018年 杨旭. All rights reserved.
//

#import "YXBankViewModel.h"
#import "YXBankModel.h"
@implementation YXBankViewModel

+ (void)getQueryBensureCardName:(NSString *)name idCardFrontImgUrl:(NSString *)idCardFrontImgUrl idCardBackImgUrl:(NSString *)idCardBackImgUrl bankNo:(NSString *)bankNo phone:(NSString *)phone vCode:(NSString *)vCode wPassword:(NSString *)wPassword cPassword:(NSString *)cPassword  ModelList:(void(^)(NSArray *listArr))mdList Failure:(void(^)(NSError *error))failure {
    
//    http://121.196.210.134:8082/mpos/wx/ensureCard.do
    NSString *urlStr = @"ensureCard.do";
    NSDictionary *paramter = @{@"name":name,
                               @"idCardFrontImgUrl":idCardFrontImgUrl,
                               @"idCardBackImgUrl":idCardBackImgUrl,
                               @"bankNo":bankNo,
                               @"phone":phone,
                               @"vCode":vCode,
                               @"wPassword":wPassword,
                               @"cPassword":cPassword,
                               @"lineNo":@""
                               };
    
    
    [BX_NetWorkManager requestForPOSTWithUrl:urlStr parameter:paramter success:^(id responseObject) {
        NSLog(@"请求成功:%@",responseObject);
        if (REQUESTDATASUCCESS) {
            
            NSArray *arr;
            if (mdList) {
                mdList(arr);
            }
        }
        
    } failure:^(NSError *error) {
        NSLog(@"请求失败:%@",error);
        if (failure) {
            failure(error);
        }
    }];
    
}


+ (void)getQueryBankListSessionId:(NSString *)sessionId ModelList:(void(^)(NSArray *listArr))mdList Failure:(void(^)(NSError *error))failure {
    
    //http://121.196.210.134:8082/mpos/wx/bank_list.do
    NSString *urlStr = @"bank_list.do";
    NSDictionary *paramter = @{@"sessionId":sessionId};
    [BX_NetWorkManager requestForPOSTWithUrl:urlStr parameter:paramter success:^(id responseObject) {
        NSLog(@"请求成功:%@",responseObject);
        if (REQUESTDATASUCCESS) {
            NSArray *listArr = [YXBankModel mj_objectArrayWithKeyValuesArray:responseObject[@"body"]];

            if (mdList) {
                mdList(listArr);
            }
        }
        
    } failure:^(NSError *error) {
        NSLog(@"请求失败:%@",error);
        if (failure) {
            failure(error);
        }
    }];
}

+ (void)getQueryCashProfitSessionId:(NSString *)sessionId BankId:(NSString *)bankId Price:(NSString *)price Password:(NSString *)password ModelList:(void(^)(NSString *price))mdList Failure:(void(^)(NSError *error))failure {
    
//    http://121.196.210.134:8082/mpos/wx/cashProfit.do
    NSString *urlStr = @"cashProfit";
    NSDictionary *paramter = @{@"sessionId":sessionId,@"bankId":bankId,@"price":price,@"password":password};
    [BX_NetWorkManager requestForPOSTWithUrl:urlStr parameter:paramter success:^(id responseObject) {
        NSLog(@"请求成功:%@",responseObject);
        if (REQUESTDATASUCCESS) {
            if (mdList) {
                mdList(price);
            }
        }
        
    } failure:^(NSError *error) {
        if (failure) {
            failure(error);
        }
    }];
    
}


@end
